(function ($) {
	
	function endsWidth(a, b) {
		if (!a)
			return false;
		
		if (!b)
			return false;
		
		var myLen = a.length;
		var itsLen = b.length;
		
		if (itsLen > myLen)
			return false;
		
		for (var j=0; j<itsLen; j++) {
			var s = myLen - j - 1;
			var t = itsLen - j - 1;
			
			if (a[s] != b[t])
				return false;
		}
		
		return true;
	}
	
	$.endsWith = endsWidth;
	
	if (typeof String.prototype.endsWith == 'undefined') {
		String.prototype.endsWith = function (value) {
			return endsWidth(this, value);
		};
	}
	
	function __ensureLength(text, len) {
		if (typeof text != 'string')
			return false;
		
		return text.length <= len;
	}

	window._ensureLength = function (label, text, len) {
		var result = __ensureLength(text, len);
		var rLen = '';
		if (typeof text === 'string')
			rLen = ', 目前' + text.length + '字';
		if (!result)
			$.zjb_dialog.alert('错误', label + '的内容不应超过' + len + '字' + rLen);
		return;
	};
	
})(jQuery);